<?php
class ChartController extends Yaf_Controller_Abstract
{
    /**
     * 聊天室
     */
    public function indexAction() {
        // 登录
        if(empty($_POST['game_id'])) {
            show('error',[],200);
        }
        if(empty($_POST['content'])) {
            show('error',[],200);
        }

        $data = [
            'user' => "用户".rand(0, 2000),
            'content' => $_POST['content'],
        ];
        //  todo
        foreach($_POST['http_server']->connections as $fd) {
            $_POST['http_server']->push($fd, json_encode($data));
        }
        show('ok',$data,200);
        return FALSE;

    }
}
